<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8" import="pojo.*,base.*,service.*,java.text.*,java.util.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript" src="jquery/jquery-1.6.1.js"></script>
<script type="text/javascript" src="jquery/jquery.validate.min.js"></script>
<script> 
$(function(){
	$("#add").click(function(){
            var name=$("#Name").val();
			var type=$("#Type").val();
			var quality=$("#Quality").val();
			var price=$("#Price").val();
			var pic=$("#pic").val();
	if(name==0){
        alert("请输入菜品名");
        $("#Name").focus();
        return false;
    }
   
   else if(type==0){
    alert("请选择菜品类型");
       return false;
    }
    else if(pic==""){
    alert("请上传图片");
    return false；
    
    }
    
    else if(quality==""){
    alert("请输入菜品构成")
    $("#namel").focus();
     return false;
     }
       else if(price==""){
    alert("请输入菜品构成")
    $("#Quality").focus();
     return false;
     }
    else{$("#form1").submit()}
    
	})
})
</script>
<script type="text/javascript">
$(function(){

	$("#upload").click(function(){
		$.ajax({
		
			type:"get",
			dataType:"json",
			url:"action/upload.jsp",
			success:function(data){
			if(data.success){
				$("#pic").val(data.path);
			}				
			}
		
		});

	})
	
})



</script>

<style type="text/css">

#box{
	border: 5px groove #CDC9C9;
	height: 500px;
	width: 500px;
	margin-left:auto;
	margin-right:auto;
}
#b1{
	height: 50px;
	width: 510px;
	margin-top: 35px;
}

#s{
   height:40px;
   width:490px;
   margin-bottom:5px;
   }
  body{
	margin:0;
	padding:20px;
	background-image:url("images/innerBJ.jpg");
	background-repeat:no-repeat;
	font:80% Arial, Helvetica, sans-serif;
	color:#555;
	line-height:100%;
}  
</style>
<script type="text/javascript" src="jquery/jquery-1.6.1.js"></script>
<script type="text/javascript" src="jquery/jquery.validate.min.js"></script>
<script type="text/javascript"></script>
</head>


<body >
<% request.setCharacterEncoding("UTF-8"); %>
	
<form id=form1" action="action/adddishesAction.jsp" method="post">
		<div id="box" >
			  <p class="STYLE2"> 菜品名称
			    <input type="text" name="Name" id="Name"/>
			  </p>
			  <p class="STYLE2"> 菜品类别
		                    <select name="Type"  id="Type" style="width:150px;">
                            <option value=0>---请选择---</option>
 <%
	                           DishesService ds = new DishesService();	
	                           List<dishesType> list1 = ds.getDishesType();	

	                           for(dishesType d:list1){
		                      
			                     out.print("<option value='"+d.getId()+"'>"+d.getName()+"</option>");
	                           } %>
 
 
                             </select>
			  </p>
			  <p class="STYLE2"> 菜品材料
               <textarea name="Quality" id="Quality"></textarea>
              </p>
              
			  <p class="STYLE2"> 菜品图片
			    <input type="text" name="Picture" id="pic"/>&nbsp;&nbsp;&nbsp;&nbsp;<a style="text-decoration:none;" href="javascript:;" id="upload">上传</a>
			  </p>
			  <p class="STYLE2"> 菜品介绍
			    <textarea name="Detail" id="Detail"></textarea>
			  </p>
			  <p class="STYLE2"> 菜品打折
			    <select name="Sale" style="width:150px;">
			    <option value=10 >---请选择---</option>
			    <option value=1>1折</option>
			    <option value=2>2折</option>
			    <option value=3>3折</option>
			    <option value=4>4折</option>
			    <option value=5>5折</option>
			    <option value=6>6折</option>
			    <option value=7>7折</option>
			    <option value=8>8折</option>
			    <option value=9>9折</option>
			    </select>
			  </p>
			   <p class="STYLE2"> 菜品价格
			    <input type="text" name="Price" id="Price"/>
			  </p>
			  <br />
			
			   <p align="center">
               <input type="submit" name="Submit" value="提交" id="add"/>&nbsp;&nbsp;&nbsp;&nbsp;<input type="reset" name="reset" value="重置">
                </p>
			  
			</div>
		
		</form>
		
		
	
</body>
</html>
